﻿var onMouseOutOpacity = 0.67;

$(function () {
    $('#announcement').jqm();
    $('#announcement').jqmShow();
    ShowGallery();
    DisableSelect();
});

function ShowGallery() {
    var gallery = $('#galleryContainer').galleriffic('#thumbsContainer', {
        delay: 3000,
        numThumbs: 11,
        preloadAhead: 11, // Set to -1 to preload all images
        enableTopPager: false,
        enableBottomPager: true,
        imageContainerSel: '#imageContainer',
        controlsContainerSel: '#controlContainer',
        captionContainerSel: '#captionContainer',
        loadingContainerSel: '#loadingContainer',
        renderSSControls: false,
        renderNavControls: false,
        playLinkText: 'Play',
        pauseLinkText: 'Pause',
        prevLinkText: 'Previous',
        nextLinkText: 'Next',
        nextPageLinkText: '下页 &rsaquo;',
        prevPageLinkText: '&lsaquo; 上页',
        enableHistory: false,
        autoStart: true,
        onChange: function (prevIndex, nextIndex) {
            $('#thumbsContainer ul.thumbs').children()
                    .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
                    .eq(nextIndex).fadeTo('fast', 1.0);
        }, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
        onTransitionOut: function (callback) {
            $('#imageContainer, #captionContainer').fadeOut('fast', callback);
        },

        onTransitionIn: function () {
            $('#imageContainer, #captionContainer').fadeIn('fast');
        },
        onPageTransitionOut: function (callback) {
            $('#thumbsContainer ul.thumbs').fadeOut('fast', callback);
        },

        onPageTransitionIn: function () {
            $('#thumbsContainer ul.thumbs').fadeIn('fast');
        }

    });

    $('#thumbsContainer ul.thumbs li').css('opacity', onMouseOutOpacity)
.hover(
    function () {
        $(this).not('.selected').fadeTo('fast', 1.0);
    },
    function () {
        $(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
    }
);
}

function DisableSelect() {
    $(document).bind("contextmenu", function (e) {
        return false;
    });

    $(document).disableTextSelect();
}
function Pause() {
    try {
        gallery.pause();
    }
    catch (err) { }
}